<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld"%>
<f:requestEncoding value="utf-8"/>
<stripes:useActionBean var="f" binding="/forum.action" />
<c:import url="header.jsp">
    <c:param name="title" value=" ${f.forum.messages.name} | Hokejové fórum pro všechny fanoušky "/>
</c:import>
<stripes:useActionBean var="add" binding="/messageAdd.action"/>
<c:if test="${sessionScope.user != null}">
    <div id="add-message">   
        <h2>Nový příspěvek</h2>
        <stripes:form beanclass="action.AddMessageActionBean" focus="">
            <table>
                <tr>
                    <th></th>                    
                    <td><stripes:textarea name="msg" class="border" rows="5" cols="90"/>
                        <stripes:errors field="msg"/>
                        <stripes:hidden name="id" value="${f.forum.messages.id}"/></td>
                    <td></td>
                </tr>
                <tr>
                    <th></th>
                    <td><stripes:submit name="add" value="Přidej"/></td>
                </tr>
            </table>
        </stripes:form>
        <p></p>
    </div>
</c:if>

<div id="messages">
    <p class="forum-path"><a href="index.action">HokejForum.cz</a> | ${f.forum.messages.name}</p>
    <c:forEach items="${f.forum.list}" var="m" varStatus="loop">
        <div class="message">
            <div class="message-info">
                <h3><a href="user.action?id=${m.idUser}">${m.user.login}</a></h3> | ${m.user.email} | <span class="time">${m.postedAt}</span>
                    <c:if test="${sessionScope.user != null}">
                        <c:if test="${sessionScope.user.admin == 1}">
                         <span class="time">   | <a href="messageDelete.action?idDelete=${m.id}&amp;idShow=${m.idForum}">smaž</a>
                            | <a href="showEdit.action?idEdit=${m.id}&amp;idShow=${m.idForum}">edituj</a>
                        </span>
                    </c:if>
                </c:if>

            </div>
            <c:choose>
                <c:when test="${loop.count % 2 == 0}">
                    <div class="message-text odd">
                    </c:when>
                    <c:otherwise>
                        <div class="message-text">
                        </c:otherwise>
                    </c:choose>
                            <p><pre>${m.text}</pre></p>
                </div>
            </div>
        </c:forEach>
    </div>
    <c:import url="footer.jsp">
    </c:import>